package com.pucheng.bracelet.ui.activity

import android.os.Bundle
import android.text.Html
import androidx.lifecycle.Observer
import com.pucheng.bracelet.R
import com.pucheng.bracelet.app.base.BaseTitleActivity
import com.pucheng.bracelet.app.ext.KEY_FEEDBACK
import com.pucheng.bracelet.data.bean.FeedbackBean
import com.pucheng.bracelet.databinding.ActivityAboutBinding
import com.pucheng.bracelet.viewmodel.FeedbackDetailsViewModel
import kotlinx.android.synthetic.main.activity_feedback_details.*
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel

/**
 * 我要反馈
 */
class FeedbackDetailsActivity : BaseTitleActivity<FeedbackDetailsViewModel, ActivityAboutBinding>() {
    override fun layoutId(): Int = R.layout.activity_feedback_details
    override fun initView(savedInstanceState: Bundle?) {
        if (intent.getSerializableExtra(KEY_FEEDBACK) != null) {
            val feedbackInfo = intent.getSerializableExtra(KEY_FEEDBACK) as FeedbackBean
            tv_feedback_title.text = feedbackInfo.title
            mViewModel.getHelpDetails(feedbackInfo.id)
        }

    }

    override fun titleText(): String = getString(R.string.feedback_details)

    override fun createObserver() {
        super.createObserver()
        mViewModel.helpDetails.observe(this, Observer {
//            tv_feedback_title.text = it.title
            wb_feedback_content.loadDataWithBaseURL(null,it.content, "text/html" , "utf-8", null)
        })
    }
}